<template>
    <div>
       <h1 id="my">{{count}}</h1>
    </div>
</template>

<script>
import {myFun} from '@/utils'
export default {
    data(){
        return{
            count:0
        }
    },
    created(){
        //创建定时器
        // this.timer=window.setInterval(()=>{
        //     console.log('定时器count的值为:',this.count);
        //     this.count++
        // },1000)
    },
    mounted(){
        document.querySelector("#my").addEventListener('click',myFun)
    },
    beforeDestroy(){
        console.log('====beforeDestroy=====');
        //销毁定时器
        window.clearInterval(this.timer)
        //解绑事件
        document.querySelector("#my").removeEventListener("click",myFun)

    }
}
</script>

<style>

</style>